From 1f1db4f28861aafe3c8611b7b0d1269f6259e8a0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 9 Apr 2009 23:42:44 -0400 Subject: [PATCH] Expand GtkBuilder migration guide --- docs/reference/gtk/migrating-GtkBuilder.sgml | 79 ++++++++++++++++---- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/docs/reference/gtk/migrating-GtkBuilder.sgml b/docs/reference/gtk/migrating-GtkBuilder.sgml index f406ab361d..a85ea68a84 100644 --- a/docs/reference/gtk/migrating-GtkBuilder.sgml +++ b/docs/reference/gtk/migrating-GtkBuilder.sgml @@ -16,14 +16,65 @@ A good way to start a migration from libglade to GtkBuilder is to run the gtk-builder-convert utility on your glade file, and inspect the resulting output. - If your code uses the @root parameter of glade_xml_new(), you + If your code uses the @root parameter of glade_xml_new(), you may want to split your glade file into multiple GtkBuilder files - by using the option of + by using the option of gtk-builder-convert. Alternatively, you can use gtk_builder_add_objects_from_file() to construct only certain objects from a GtkBuilder file. + + Alternatively, you can open the glade file with + glade3 and then save it in GtkBuilder + format. This is supported by glade3 since version 3.6. + + + + Step-by-step instructions for porting code from libglade to GtkBuilder + + + libgladeGtkBuilder + + + + ]]> + not needed + + + GladeXML* + GtkBuilder* + + + glade_xml_new (FILE, "first_widget", NULL) + + +GError* error = NULL; +GtkBuilder* builder = gtk_builder_new (); +if (!gtk_builder_add_from_file (builder, FILE, &error)) + { + g_warning ("Couldn't load builder file: %s", error->message); + g_error_free (error); + } + + + + + glade_xml_get_widget (gxml, “widget_name”) + GTK_WIDGET (gtk_builder_get_object (builder, “widget_name”)) + + + glade_get_widget_name (widget) + gtk_widget_get_name (widget) + + + glade_xml_get_widget_prefix (gxml, “prefix”) + can be emulated by gtk_builder_get_objects (builder) together with manual filtering. It returns a GSList* instead of a GList* though. + + + +
+ While GtkBuilder strives to be a complete replacement for libglade, there are a number of areas where it is currently @@ -32,21 +83,23 @@ GtkBuilder supports context information in translatable - properties in a slightly different way than libglade. - Intltool does not yet support this; see - bug - 454894 for the current status of intltool support for - GtkBuilder files. Thankfully, context in translations is a - rarely used feature, and if you are not using it, intltools + properties in a slightly different way than libglade. + Intltool does not yet support this; see + bug + 454894 for the current status of intltool support for + GtkBuilder files. Thankfully, context in translations is a + rarely used feature, and if you are not using it, intltools glade format support works just fine for GtkBuilder files. + + While libglade can often tolerate multiple widgets having the + same id in a glade file, GtkBuilder will not accept duplicate + object ids. Both gtk-builder-convert + and the GtkBuilder parser emit warnings when they see + duplicate ids. + - - More details about migrating from libglade to GtkBuilder will - appear here over time... - - -- 2.30.2